package homework.api.day04._cp;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class SortList {
    public static void main(String[] args) {
        List<Integer> list1 = new ArrayList<>();
        list1.add(9);
        list1.add(1);
        list1.add(7);
        list1.add(3);
        list1.add(5);
        System.out.println("list1排序前"+list1);
        Collections.sort(list1);
        System.out.println("list1排序后"+list1);

        List<String> list2 = new ArrayList<>();
        list2.add("啊啊");
        list2.add("取钱少时诵诗书所");
        list2.add("王五灌灌灌灌");
        list2.add("嗯嗯嗯");
        list2.add("柔柔弱弱");
        System.out.println("list2排序前"+list2);
        list2.sort((o1,o2)->o2.length()-o1.length());
        System.out.println("list2排序后"+list2);

        List<Point> list3 = new ArrayList<>();
        list3.add(new Point(1,2));
        list3.add(new Point(222,333));
        list3.add(new Point(42,65));
        list3.add(new Point(98,75));
        list3.add(new Point(10,12));
        System.out.println("list3排序前"+list3);
        Collections.sort(list3,(o1,o2)->{
            return o1.getY()-o2.getY();
        });
        System.out.println("list3排序后"+list3);
    }
}
